#include"common.h"
#include<fcntl.h>
#include<string.h>
#include<sys/socket.h>

//Client
const u_int16_t CLIENT_ACEP_PORT=43212;
const u_int16_t CLIENT_SEND_PORT=43213;

//Server
const u_int16_t SERVER_ACEP_PORT=43211;
const char* SERVER_IP_ADDR="127.0.0.1";
const u_int32_t LISTEN_BACK_LOG=128;
const u_int32_t MAX_EVENTS_NUM=128;
const u_int32_t MAX_USER_NUM=5;

//User
#define USER_NAME_LEN 20
#define INFO_LEN 40

void make_nonblocking(int fd) {
    fcntl(fd, F_SETFL, O_NONBLOCK);  
}

int send_msg(int sockfd,Message msg){
    char buf[128];
    memset(buf,0,sizeof(buf));
    memcpy(buf,&msg,sizeof(Message));
    return send(sockfd,buf,sizeof(Message),0);
}

//Game
const int BATTLE_INIT_HP=3;

//About Message 
const char* REGISTER_NAME_REPEATED_INFO="The user name has been registered!";
const char* REGISTER_SESSION_EXIST_INFO="You has been registered!";

const char* USER_OFFLINE_INFO="The user is not online!";
const char* FRIEND_ADDED_INFO="The user has already been your friend!";

const char* BATTLE_CLOSE_INFO="Batlle has been closed!";